<%@page import="java.sql.ResultSet"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.lovemanai.dao.DbDao" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title>My JSP 'index.jsp' starting page</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
  </head>
  
  <%
  	//数据库连接参数
  	String url = "jdbc:mysql://localhost:3306/crazyit";
	String user = "root";
	String password = "root";
	String driver = "com.mysql.jdbc.Driver";
	
	DbDao dbDao = new DbDao(url, user, password, driver);
	
	String sql = "select * from userinfo";
	ResultSet rs = dbDao.query(sql);
  %>
  
  <body>
    <table width="500px" border="1px">
    	<%
    		try {
    			while(rs.next()) {
    	%>
    	<tr>
    		<td><%=rs.getString("sessionid") %></td>
    		<td><%=rs.getString("username") %></td>
    		<td><%=rs.getString("ip") %></td>
    		<td><%=rs.getString("page") %></td>
    	</tr>
    	<%
    			}
    		} catch(Exception e) {
    			e.printStackTrace();
    		}
    	%>
    </table>
  </body>
</html>
